#ifndef X_COMMON
#define X_COMMON

#include "inc_structs.fxh"
#include "inc_macros.fxh"
#include "inc_lighting.fxh"

float4x4 World;
float4x4 View;
float4x4 Projection;

//AlphaBlendEnable = TRUE;
//DestBlend = INVSRCALPHA;
//SrcBlend = SRCALPHA;

float2 ProjectedCoords(float4 position)
{
	float2 ProjectedTexCoords;
	ProjectedTexCoords[0] = position.x / position.w / 2.0f + 0.5f;
	ProjectedTexCoords[1] = -position.y / position.w / 2.0f + 0.5f;

	return ProjectedTexCoords;
}

float4 DistanceFromCamera(float4 position)
{
	return distance(float3(-View[0][3], -View[1][3], -View[2][3]), position);
}

float4 CalcPos(float4 position)
{
	return mul(mul(mul(position, World), View), Projection);
}

float4 CalcNormal(float3 normal)
{
	return normalize(mul(normal, World));
}

float4 CalcPosHI(float4 position, float4x4 transform)
{
	return mul(mul(mul(position, transform), View), Projection);
}

#endif